This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(Seurat)
library(tidyverse)
library(here)
source(here('vignettes', 'bcells', 'common.R'))
Parsed with column specification:
cols(
`MGI Gene/Marker ID` = col_character(),
Symbol = col_character(),
Name = col_character(),
Chr = col_character(),
Qualifier = col_character(),
`Annotated Term` = col_character(),
Context = col_character(),
Proteoform = col_character(),
Evidence = col_character(),
`Inferred From` = col_character(),
`Reference(s)` = col_character(),
category = col_character()
)
load(here('vignettes', 'bcells', 'droplet_cd19.Robj'))
cluster.markers = FindAllMarkers(object = tiss_droplet_cd19, only.pos = TRUE, min.pct = 0.25, thresh.use = 0.25)
| | 0 % ~calculating
|+ | 1 % ~16s
|++ | 2 % ~14s
|++ | 4 % ~13s
|+++ | 5 % ~13s
|+++ | 6 % ~12s
|++++ | 7 % ~12s
|+++++ | 8 % ~12s
|+++++ | 9 % ~12s
|++++++ | 11% ~11s
|++++++ | 12% ~11s
|+++++++ | 13% ~11s
|++++++++ | 14% ~11s
|++++++++ | 15% ~11s
|+++++++++ | 16% ~11s
|+++++++++ | 18% ~10s
|++++++++++ | 19% ~10s
|++++++++++ | 20% ~10s
|+++++++++++ | 21% ~10s
|++++++++++++ | 22% ~10s
|++++++++++++ | 24% ~10s
|+++++++++++++ | 25% ~09s
|+++++++++++++ | 26% ~09s
|++++++++++++++ | 27% ~09s
|+++++++++++++++ | 28% ~09s
|+++++++++++++++ | 29% ~09s
|++++++++++++++++ | 31% ~09s
|++++++++++++++++ | 32% ~09s
|+++++++++++++++++ | 33% ~08s
|++++++++++++++++++ | 34% ~08s
|++++++++++++++++++ | 35% ~08s
|+++++++++++++++++++ | 36% ~08s
|+++++++++++++++++++ | 38% ~08s
|++++++++++++++++++++ | 39% ~08s
|++++++++++++++++++++ | 40% ~07s
|+++++++++++++++++++++ | 41% ~07s
|++++++++++++++++++++++ | 42% ~07s
|++++++++++++++++++++++ | 44% ~07s
|+++++++++++++++++++++++ | 45% ~07s
|+++++++++++++++++++++++ | 46% ~07s
|++++++++++++++++++++++++ | 47% ~07s
|+++++++++++++++++++++++++ | 48% ~06s
|+++++++++++++++++++++++++ | 49% ~06s
|++++++++++++++++++++++++++ | 51% ~06s
|++++++++++++++++++++++++++ | 52% ~06s
|+++++++++++++++++++++++++++ | 53% ~06s
|++++++++++++++++++++++++++++ | 54% ~06s
|++++++++++++++++++++++++++++ | 55% ~06s
|+++++++++++++++++++++++++++++ | 56% ~05s
|+++++++++++++++++++++++++++++ | 58% ~05s
|++++++++++++++++++++++++++++++ | 59% ~05s
|++++++++++++++++++++++++++++++ | 60% ~05s
|+++++++++++++++++++++++++++++++ | 61% ~05s
|++++++++++++++++++++++++++++++++ | 62% ~05s
|++++++++++++++++++++++++++++++++ | 64% ~04s
|+++++++++++++++++++++++++++++++++ | 65% ~04s
|+++++++++++++++++++++++++++++++++ | 66% ~04s
|++++++++++++++++++++++++++++++++++ | 67% ~04s
|+++++++++++++++++++++++++++++++++++ | 68% ~04s
|+++++++++++++++++++++++++++++++++++ | 69% ~04s
|++++++++++++++++++++++++++++++++++++ | 71% ~04s
|++++++++++++++++++++++++++++++++++++ | 72% ~03s
|+++++++++++++++++++++++++++++++++++++ | 73% ~03s
|++++++++++++++++++++++++++++++++++++++ | 74% ~03s
|++++++++++++++++++++++++++++++++++++++ | 75% ~03s
|+++++++++++++++++++++++++++++++++++++++ | 76% ~03s
|+++++++++++++++++++++++++++++++++++++++ | 78% ~03s
|++++++++++++++++++++++++++++++++++++++++ | 79% ~03s
|++++++++++++++++++++++++++++++++++++++++ | 80% ~02s
|+++++++++++++++++++++++++++++++++++++++++ | 81% ~02s
|++++++++++++++++++++++++++++++++++++++++++ | 82% ~02s
|++++++++++++++++++++++++++++++++++++++++++ | 84% ~02s
|+++++++++++++++++++++++++++++++++++++++++++ | 85% ~02s
|+++++++++++++++++++++++++++++++++++++++++++ | 86% ~02s
|++++++++++++++++++++++++++++++++++++++++++++ | 87% ~02s
|+++++++++++++++++++++++++++++++++++++++++++++ | 88% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++ | 89% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++ | 91% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++ | 92% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 93% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 94% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 95% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 12s
| | 0 % ~calculating
|+ | 2 % ~09s
|++ | 3 % ~09s
|+++ | 5 % ~08s
|++++ | 6 % ~08s
|++++ | 8 % ~08s
|+++++ | 10% ~08s
|++++++ | 11% ~08s
|+++++++ | 13% ~08s
|++++++++ | 14% ~08s
|++++++++ | 16% ~07s
|+++++++++ | 17% ~07s
|++++++++++ | 19% ~07s
|+++++++++++ | 21% ~07s
|++++++++++++ | 22% ~07s
|++++++++++++ | 24% ~07s
|+++++++++++++ | 25% ~07s
|++++++++++++++ | 27% ~07s
|+++++++++++++++ | 29% ~06s
|++++++++++++++++ | 30% ~06s
|++++++++++++++++ | 32% ~06s
|+++++++++++++++++ | 33% ~06s
|++++++++++++++++++ | 35% ~06s
|+++++++++++++++++++ | 37% ~06s
|++++++++++++++++++++ | 38% ~06s
|++++++++++++++++++++ | 40% ~05s
|+++++++++++++++++++++ | 41% ~05s
|++++++++++++++++++++++ | 43% ~05s
|+++++++++++++++++++++++ | 44% ~05s
|++++++++++++++++++++++++ | 46% ~05s
|++++++++++++++++++++++++ | 48% ~05s
|+++++++++++++++++++++++++ | 49% ~05s
|++++++++++++++++++++++++++ | 51% ~04s
|+++++++++++++++++++++++++++ | 52% ~04s
|+++++++++++++++++++++++++++ | 54% ~04s
|++++++++++++++++++++++++++++ | 56% ~04s
|+++++++++++++++++++++++++++++ | 57% ~04s
|++++++++++++++++++++++++++++++ | 59% ~04s
|+++++++++++++++++++++++++++++++ | 60% ~04s
|+++++++++++++++++++++++++++++++ | 62% ~03s
|++++++++++++++++++++++++++++++++ | 63% ~03s
|+++++++++++++++++++++++++++++++++ | 65% ~03s
|++++++++++++++++++++++++++++++++++ | 67% ~03s
|+++++++++++++++++++++++++++++++++++ | 68% ~03s
|+++++++++++++++++++++++++++++++++++ | 70% ~03s
|++++++++++++++++++++++++++++++++++++ | 71% ~03s
|+++++++++++++++++++++++++++++++++++++ | 73% ~02s
|++++++++++++++++++++++++++++++++++++++ | 75% ~02s
|+++++++++++++++++++++++++++++++++++++++ | 76% ~02s
|+++++++++++++++++++++++++++++++++++++++ | 78% ~02s
|++++++++++++++++++++++++++++++++++++++++ | 79% ~02s
|+++++++++++++++++++++++++++++++++++++++++ | 81% ~02s
|++++++++++++++++++++++++++++++++++++++++++ | 83% ~02s
|+++++++++++++++++++++++++++++++++++++++++++ | 84% ~01s
|+++++++++++++++++++++++++++++++++++++++++++ | 86% ~01s
|++++++++++++++++++++++++++++++++++++++++++++ | 87% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++ | 89% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++ | 90% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 92% ~01s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 94% ~01s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 95% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 98% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed = 09s
cluster.markers %>% group_by(cluster) %>% top_n(-10, p_val_adj)
write_markers(cluster.markers, here('vignettes', 'bcells', 'droplet_cluster_markers.csv'))
top_cluster_markers = cluster.markers %>% group_by(cluster) %>% top_n(-10, p_val_adj)
nCol = 4
plots = FeaturePlot(tiss_droplet_cd19, features.plot = sort(unique(top_cluster_markers$gene)),
do.return = TRUE, nCol = nCol, no.axes=TRUE,
# Light grey to
cols.use=c('lightgrey', '#008080'))
for (p in plots){
gene_name = p$labels$title
gene_tissues = top_organ_markers %>% filter(gene == p$labels$title) %>% select(tissue)
gene_tissues = as.character(as.vector(gene_tissues$tissue))
print(paste(gene_name, paste(gene_tissues)))
title = paste0(gene_name, ' (', paste(gene_tissues, sep=', '), ')')
p = p + labs(title=title)
plots[[gene_name]] = p
}
Error in eval(lhs, parent, parent) : object 'top_organ_markers' not found
rr organ_markers = find_markers(tiss_droplet_cd19, ‘tissue’) head(organ_markers)
Filter only for tissues with enough cells
rr tissue_cell_counts = table(tiss_droplet_cd19@meta.data$tissue) print(tissue_cell_counts)
tissues_with_enough_cells = tissue_cell_counts[tissue_cell_counts > 50] tissues_with_enough_cells
rr organ_markers_enough_cells = filter(organ_markers, tissue %in% names(tissues_with_enough_cells)) organ_markers_enough_cells
rr top_organ_markers = organ_markers_enough_cells %>% group_by(tissue) %>% top_n(-10, p_val_adj) top_organ_markers
rr write_csv(organ_markers_enough_cells, here(‘vignettes’, ‘bcells’, ‘droplet_tissue_markers.csv’))
rr ggplot(data=organ_markers_enough_cells, aes(x=p_val)) + geom_histogram() + facet_grid(~tissue)
rr ggplot(data=organ_markers_enough_cells, aes(x=p_val_adj)) + geom_histogram() + facet_grid(~tissue)
rr top_organ_markers %>% filter(gene == p\(labels\)title) %>% select(tissue)
rr nCol = 4 plots = FeaturePlot(tiss_droplet_cd19, features.plot = sort(unique(top_organ_markers\(gene)), do.return = TRUE, nCol = nCol, no.axes=TRUE, # Light grey to cols.use=c('lightgrey', '#008080')) for (p in plots){ gene_name = p\)labels\(title gene_tissues = top_organ_markers %>% filter(gene == p\)labels\(title) %>% select(tissue) gene_tissues = as.character(as.vector(gene_tissues\)tissue)) print(paste(gene_name, paste(gene_tissues))) title = paste0(gene_name, ‘(’, paste(gene_tissues, sep=‘,’), ‘)’) p = p + labs(title=title) plots[[gene_name]] = p } plots.combined <- plot_grid(plotlist = plots, ncol = nCol) invisible(x = lapply(X = plots.combined, FUN = print)) ggsave(‘droplet_featureplot_top_organ_markers.pdf’, height = 40, width=15)